DeepWiki

05.b - Repository-Cloning-Automation

Relevant source files

This document details the automated repository cloning pipeline that processes customer repositories after GitHub App installation. The pipeline extracts installation IDs from ntfy notifications, generates access tokens, clones customer repositories, and creates private mirrors in the klaudioz GitHub account.

For information about the ntfy message broker integration, see ntfy Integration & Message Broker. For details about the automation script variants and setup, see Automation Scripts.

Sources: scripts/README.md L1-L81

CLAUDE.md L1-L224


The automation pipeline operates as a stateless, event-driven system triggered by ntfy notifications containing GitHub installation details.

Sources: scripts/ntfy-godeep-automation.sh L1-L152

scripts/README.md L36-L51


The script listens for ntfy notifications and filters for GitHub installation events using title pattern matching.

OperationImplementationLine Reference
Subscribe to topicntfy subscribe "$TOPIC"scripts/ntfy-godeep-automation.sh L39
Parse JSONjq -r '.message // empty'scripts/ntfy-godeep-automation.sh L41-L42
Title filteringgrep -q "GitHub Connected|GitHub Installation"scripts/ntfy-godeep-automation.sh L49
Extract IDgrep -o 'Installation ID: [0-9]*'scripts/ntfy-godeep-automation.sh L53

The extraction uses macOS-compatible regex patterns to parse the installation ID from notification messages containing the format Installation ID: 12345678.

Sources: scripts/ntfy-godeep-automation.sh L39-L54


The script authenticates with the admin API to generate installation access tokens with repository metadata.

Request Payload Structure:

{  "installationId": "12345678",  "password": "<ADMIN_PASSWORD from .env>"}

Response Structure Extraction:

Sources: scripts/ntfy-godeep-automation.sh L16-L28

scripts/ntfy-godeep-automation.sh L62-L72


The script clones the customer repository using GitHub's token-based authentication over HTTPS.

Clone Command Pattern:

git clone "https://x-access-token:${token}@github.com/${repo_full_name}.git" "$clone_path"

Directory Path Construction:

  1. Extract email prefix: sed 's/@/_/g; s/\./_/g' (scripts/ntfy-godeep-automation.sh L80 )
  2. Convert to lowercase: tr '[:upper:]' '[:lower:]' (scripts/ntfy-godeep-automation.sh L80 )
  3. Format as: email_prefix-repo_name (scripts/ntfy-godeep-automation.sh L81 )
  4. Full path: $HOME/godeep-clones/email_prefix-repo_name (scripts/ntfy-godeep-automation.sh L87 )

Example Transformations:

Customer EmailRepository NameFormatted Path
user@example.commy-app~/godeep-clones/user_example_com-my-app
John.Doe@Company.ioapi-server~/godeep-clones/john_doe_company_io-api-server

Sources: scripts/ntfy-godeep-automation.sh L78-L90


After cloning, the script removes the original Git history and creates a new repository to avoid linking to the customer's repository.

Re-initialization Sequence:

Commit Message Format:

Initial commit from GoDeep.wiki customer: <customer_email>

This preserves the customer identifier for tracking purposes while creating an independent Git history.

Sources: scripts/ntfy-godeep-automation.sh L100-L103


The script uses GitHub CLI (gh) to create private repositories in the klaudioz account.

Creation Command:

gh repo create "klaudioz/$formatted_repo_name" --private --source=. --push

Command Breakdown:

FlagPurposeDetails
klaudioz/$formatted_repo_nameRepository pathOwner/repo format with formatted name
--privateVisibilityEnsures repository is not public
--source=.Source directoryCurrent directory (cloned repo)
--pushAuto-pushImmediately pushes commits to new repo

Authentication Requirement: The gh CLI must be authenticated with credentials that have repository creation permissions on the klaudioz account. This is separate from the installation access token used for cloning.

Sources: scripts/ntfy-godeep-automation.sh L106-L117

scripts/README.md L30-L31


The script deletes local clones after successful repository creation to conserve disk space.

Cleanup Flow:

Critical Safety Measure: The script always changes back to the parent directory with cd - > /dev/null before deletion (scripts/ntfy-godeep-automation.sh L110

scripts/ntfy-godeep-automation.sh L122

) to prevent deleting the current working directory.

Disk Space Management:

  • Clones are temporary and immediately deleted after processing
  • Failed clones are also deleted to prevent orphaned directories
  • Clone directory is ~/godeep-clones/ (scripts/ntfy-godeep-automation.sh L8 )

Sources: scripts/ntfy-godeep-automation.sh L109-L130


Sources: scripts/ntfy-godeep-automation.sh L39-L151


The script maintains a structured directory hierarchy for temporary clones:

$HOME/
└── godeep-clones/
    ├── user_example_com-frontend-app/    # Temporary (deleted after push)
    ├── john_doe_company_io-api-server/    # Temporary (deleted after push)
    └── admin_test_org-microservice/       # Temporary (deleted after push)

Directory Configuration:

Formatting Rules:

StepOperationCode Reference
1. Extract emailjq -r '.user.email // .user.username // empty'scripts/ntfy-godeep-automation.sh L71
2. Replace @ and .sed 's/@/_/g; s/\./_/g'scripts/ntfy-godeep-automation.sh L80
3. Lowercasetr '[:upper:]' '[:lower:]'scripts/ntfy-godeep-automation.sh L80
4. Combine"${email_prefix}-${repo_name}"scripts/ntfy-godeep-automation.sh L81
5. FallbackIf no email, use "$repo_name"scripts/ntfy-godeep-automation.sh L83

Result: GitHub repository at github.com/klaudioz/email_prefix-repo_name

Sources: scripts/ntfy-godeep-automation.sh L78-L87


The script provides visual feedback through macOS osascript notifications at each stage:

EventNotification TitleMessage ContentLine Reference
Installation detected"GoDeep.wiki Automation""Processing Installation ID: {id}"scripts/ntfy-godeep-automation.sh L59
Clone complete"✅ GoDeep.wiki - Clone Complete""Repository cloned to {path}"scripts/ntfy-godeep-automation.sh L94
Repo created"✅ GoDeep.wiki - Complete!""Repository created: klaudioz/{name}"scripts/ntfy-godeep-automation.sh L117
Repo creation failed"❌ GoDeep.wiki Error""Failed to create repo: {name}"scripts/ntfy-godeep-automation.sh L129
Clone failed"❌ GoDeep.wiki Error""Clone failed for {repo}"scripts/ntfy-godeep-automation.sh L134
Token generation failed"❌ GoDeep.wiki Error""Failed to process Installation ID: {id}"scripts/ntfy-godeep-automation.sh L139

Notification Command Pattern:

osascript -e "display notification \"<message>\" with title \"<title>\""

Error Recovery:

  • The script never exits on errors; it continues listening for new notifications
  • Failed clones are deleted to prevent disk space accumulation
  • Errors are logged to stdout with emoji indicators (❌, ⚠️)

Sources: scripts/ntfy-godeep-automation.sh L117-L148


The pipeline uses two distinct authentication mechanisms:

StageToken TypeUsageExpiry
CloneInstallation access tokenx-access-token in git URL1 hour
PushGitHub CLI credentialsgh authenticated sessionPersistent

Installation Token Usage:

git clone "https://x-access-token:${token}@github.com/${repo_full_name}.git"

The x-access-token is a special GitHub authentication mechanism that accepts any value as the username when using a personal access token or installation token.

Sources: scripts/ntfy-godeep-automation.sh L90


Environment Variables:

VariablePurposeLine Reference
TOPICntfy.sh topic namescripts/ntfy-godeep-automation.sh L6
ADMIN_URLAdmin API endpointscripts/ntfy-godeep-automation.sh L7
CLONE_DIRBase clone directoryscripts/ntfy-godeep-automation.sh L8
SCRIPT_DIRScript locationscripts/ntfy-godeep-automation.sh L11
PROJECT_ROOTProject root directoryscripts/ntfy-godeep-automation.sh L13
ENV_FILEPath to .env filescripts/ntfy-godeep-automation.sh L16
ADMIN_PASSWORDAdmin API passwordscripts/ntfy-godeep-automation.sh L23

Path Resolution Strategy: The script uses $( cd ... && pwd ) for absolute path resolution (scripts/ntfy-godeep-automation.sh L11-L13

), ensuring it can be executed from any directory.

Sources: scripts/ntfy-godeep-automation.sh L6-L28


The script uses jq for JSON processing at multiple stages:

Notification Parsing:

message=$(echo "$line" | jq -r '.message // empty')title=$(echo "$line" | jq -r '.title // "ntfy"')

API Response Parsing:

token=$(echo "$response" | jq -r '.token // empty')repo_full_name=$(echo "$response" | jq -r '.repositories[0].full_name // empty')repo_name=$(echo "$response" | jq -r '.repositories[0].name // empty')customer_email=$(echo "$response" | jq -r '.user.email // .user.username // empty')

Fallback Strategy:

  • Uses // empty to return empty string if field is missing
  • Uses // .user.username as fallback if email is unavailable
  • Checks for empty strings before proceeding with processing

Sources: scripts/ntfy-godeep-automation.sh L41-L42

scripts/ntfy-godeep-automation.sh L68-L71


Required Tool Installations:

  • ntfy: Message subscription client
  • jq: JSON parsing utility
  • git: Repository cloning
  • gh: GitHub CLI for repository creation
  • osascript: macOS notification system (built-in)

Sources: scripts/README.md L67-L71

Refresh this wiki

Last indexed: 23 November 2025 (922b35)

On this page

Ask Devin about godeep.wiki-jb

Syntax error in text

mermaid version 11.4.1

05.b - Repository-Cloning-Automation | DeepWiki | godeep.wiki